﻿using System;
using SDT.CodeSystem;

namespace SDT.CrawlSystem.Tools.Data
{
    internal static class Repository
    {
        public static bool Insert(CityCodes.Codes c, CityCodes.Codes? a, string name, int prio)
        {
            var db = new DbDataContext();

            try
            {
                return db.sp_ad_cities_insert(CityCodes.ToString(c), a == null ? null : CityCodes.ToString((CityCodes.Codes)a), name, (byte)prio) > 0;
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                db.Dispose();
            }
        }

        public static bool Insert(CityCodes.Codes c, string name, string sname)
        {
            var db = new DbDataContext();

            try
            {
                return db.sp_ad_districts_insert(CityCodes.ToString(c), name, sname) > 0;
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                db.Dispose();
            }
        }
    }
}